import java.util.Scanner;

public class Practice01 {
    public Practice01() {
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3};
        System.out.println("请输入你想查找的数字 ->");
        Scanner scanner = new Scanner(System.in);
        int target = scanner.nextInt();
        int first = 0;
        int last = arr.length - 1;

        while(first <= last) {
            int mid = (last + first) / 2;
            if (target == arr[mid]) {
                System.out.println("在index = " + mid + "的位置上找到" + target + "了");
                break;
            }

            if (target > arr[mid]) {
                first = mid + 1;
            } else if (target < arr[mid]) {
                last = mid - 1;
            }
        }

        if (first > last) {
            System.out.println("没有找到" + target);
        }

    }
}